﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bzure.Common.Transactions;
using Bzure.Security.Principal;
using Bzure.Common.Core;

namespace Bzure.Security
{
    [EnumStringsAttribute(typeof(CreateUserResult), "成功", "用户名已经存在", "用户ID已经存在","用户邮箱已经存在","已经存在","其他原因失败")]
    public enum CreateUserResult
    {
        Success = 0,//成功
        UserNameExists = 1,//用户名已经存在
        UserIDExists = 2,//用户ID已经存在
        EMailExists=4,//用户邮箱已经存在
        OpenIDExists=8,//OpenID已经存在
        OtherFailed = 16//其他原因失败
    }
    public interface IAccountContract : ITransactionSupport
    {
        #region 用户
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Password">密码密文</param>
        /// <returns></returns>
        bool ValidateUser(string UserName, string Password);

        /// <summary>
        /// 创建新用户
        /// </summary>
        /// <param name="User"></param>
        /// <returns>是否成功</returns>
        CreateUserResult CreateUser(BzureUser User);
        /// <summary>
        /// 改变用户密码
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Password">密码密文</param>
        /// <returns>是否成功</returns>
        bool SetPassword(string UserName, string Password);
        /// <summary>
        /// 设置用户状态
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="State"></param>
        /// <returns></returns>
        bool SetUserState(string UserName, int State);
        /// <summary>
        /// 用户是否存在
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        bool ExistsUserName(string UserName);
        /// <summary>
        /// 用户是否存在
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        bool ExistsUserID(string UserID);
        /// <summary>
        /// 获取用户实体
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        BzureUser GetUserByName(string UserName);
        /// <summary>
        /// 获取用户实体
        /// </summary>
        /// <param name="OpenID">OpenID</param>
        /// <returns></returns>
        BzureUser GetUserByOpenID(string OpenID);
        /// <summary>
        /// 加密密码
        /// </summary>
        /// <param name="password">密码明文</param>
        /// <returns>密码密文</returns>
        string EncryptPassword(string password);
        /// <summary>
        /// 获取用户的密码找回令牌
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        PasswordToken GetUserPasswordToken(string UserName);
        /// <summary>
        /// 获取用户的密码找回令牌
        /// </summary>
        /// <param name="Token">令牌</param>
        /// <returns></returns>
        PasswordToken GetPasswordToken(string Token);
        #endregion

    }
}
